<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录功能</title>
    <script src="static/script/jquery-1.8.3.js"></script>
    <script>
        /**
         * JSON数据和JS对象的区别
         * JS:{name:"Giles",age:13}
         * JSON  {"name":"Giles","age":13}
         * 将JS对象转成JSON格式的数据：JSON.stringify()
         * 将JSON格式的数据转成JS对象：JSON.parse
         */
        $(function () {
            $("#submit").click(function () {
                $.ajax({
                    url:"login",
                    type:"POST",
                    data:JSON.stringify({telephone:$("#telephone").val(),password:$("#password").val()}),
                    success:function (data) {

                    },
                    dataType:"JSON",
                    contentType:"application/json;charset=UTF-8"
                });
            });
            $("#testResultful").click(function () {
                $.ajax({
                    url:"depts",
                    type:"POST",
                    success:function (data) {
                        if(data.code==200){
                            $("#msgdiv").html(data.msg);
                        }
                    },
                    contentType:"application/json;charset=UTF-8",
                    dataType:"json"
                });
            });
        })
    </script>
</head>
<body>
    <h2>用户登录</h2>
    手机号:<input type="text" id="telephone"><br>
    密码：<input type="text" id="password"><br>
    <input type="button" value="登录" id="submit">



    <input type="button" value="测试Restful" id="testResultful"><br>
    <div id="msgdiv">

    </div>


<hr>
    <a href="testException1">没有异常处理</a><br>
    <a href="testException2">使用简单异常处理器处理异常</a><br>
    <a href="testException3">使用简单异常处理器处理特定异常</a><br>
</body>
</html>
